package com.duolaibei.business.view.goods;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.duolaibei.business.R;
import com.duolaibei.business.base.BaseActivity;
import com.duolaibei.business.utils.FragmentManager;
import com.duolaibei.business.utils.inject.Inject;
import com.duolaibei.business.view.goods.fragment.GoodTypesFragment;
import com.duolaibei.business.view.goods.fragment.GoodsListFragment;
import com.duolaibei.business.view.goods.mode.TypesBean;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/9/28.
 */
public class GoodsManageActivity extends BaseActivity {
    @Inject(R.id.back)//返回
    private RelativeLayout mBack;
    @Inject(R.id.title)//标题
    private TextView mTitle;
    @Inject(R.id.btn_flei_edit)//分类管理
    private TextView mGoodsEdit;
    @Inject(R.id.btn_edit_right)
    private TextView mGoodsAdd;//商品增加

    private FragmentManager mFragmentManagerType;//fragment管理
    private FragmentManager mFragmentManagerGood;//fragment管理
    private GoodTypesFragment mFragmentTypes;//商品类型
    private GoodsListFragment mFragmentGoods;//商品


    @Override
    protected void onSetContentView() {
        setContentView(R.layout.activity_goods_manage);
    }

    @Override
    protected void initViews() {
        mTitle.setText("商品管理");
    }

    @Override
    protected void afterOnCreate(Bundle savedInstanceState) {
        initTypesFragment();
        initGoodsFragment();
    }

    @Override
    protected void onSetListener() {
        mBack.setOnClickListener(getThis());
        mGoodsEdit.setOnClickListener(getThis());
        mGoodsAdd.setOnClickListener(getThis());
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.back) {
            finish();
        } else if (v.getId() == R.id.btn_flei_edit) {
            Intent intent = new Intent(getThis(), TypesManegeActiviy.class);

            startActivity(intent);
        } else if (v.getId() == R.id.btn_edit_right) {
            Intent intent = new Intent(getThis(), GoodsAddActivity.class);
            startActivity(intent);
        }
    }


    /**
     * 初始化类型fragment
     */
    private void initTypesFragment() {
        mFragmentManagerType = initFragmentManager(R.id.fragment_types);
        Bundle bundle = new Bundle();
//        bundle.putString(Constant.LOGIN_ID, login_id);
        mFragmentTypes = new GoodTypesFragment();
        mFragmentTypes.setArguments(bundle);
        mFragmentManagerType.showFragment(mFragmentTypes);
    }

    /**
     * 初始化商品fragment
     */
    private void initGoodsFragment() {
        mFragmentManagerGood = initFragmentManager(R.id.fragment_types);
        Bundle bundle = new Bundle();
//        bundle.putString(Constant.LOGIN_ID, login_id);
        mFragmentTypes = new GoodTypesFragment();
        mFragmentTypes.setArguments(bundle);
        mFragmentManagerGood.showFragment(mFragmentTypes);
    }
}
